#ifndef _JTIME_H
#define _JTIME_H

#include <ctime>

class jtime{
	public:
		jtime():ticks_(0),start_(0),end_(0) {  }
		~jtime(){ }

		void start() {
			start_ = clock();
			end_ = start_;
		}

		void end() {
			end_ = clock();
			ticks_ += end_-start_;
			start_ = end_;
		}

		void reset() {
			start_ = 0;
			end_ = 0;
			ticks_= 0;
		}

		void restart() {
			start_ = clock();
			end_ = start_;
			ticks_= 0;
		}

		clock_t get() {
			return ticks_;
		}

		void print(std::ostream& os = std::cout) {
//			os<<"Ticks:"<<ticks_<<std::endl;
			os<<"Seconds:"
				<<static_cast<double>(ticks_)/CLOCKS_PER_SEC
				<<std::endl;
		}

	private:
		clock_t ticks_;
		clock_t start_;
		clock_t end_;
};

#endif
